//
//  RsetaruantsTableViewCell.m
//  FoodFamily
//
//  Created by dlios on 15-6-20.
//  Copyright (c) 2015年 guoBang. All rights reserved.
//

#import "RsetaruantsTableViewCell.h"

#define HEITH1 HEIGHT / 4

@implementation RsetaruantsTableViewCell

//- (void)awakeFromNib {
//    // Initialization code
//}
//
//- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
//    [super setSelected:selected animated:animated];
//
//    // Configure the view for the selected state
//}



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatSubCell];
    }
    
    return self;

}

-(void)creatSubCell{
   
    if (WIDTH <= 414 && HEIGHT <= 736) {
        self.imageV = [[UIImageView alloc]initWithFrame:CGRectMake(5,self.frame.size.height /3, HEITH1 /5 *4,HEITH1 /5 *4)];
        self.imageV.backgroundColor = [UIColor whiteColor];
        self.imageV.layer.cornerRadius =(HEITH1 /5 *4)/2;
        self.imageV.layer.masksToBounds = YES;
        [self.contentView addSubview:self.imageV];
        
        self.category = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/5*2, HEITH1/8, WIDTH/3, HEITH1/5)];
        
        [self addSubview:self.category];
        self.category.font = [UIFont systemFontOfSize:17];
        
        
        UIImageView *imageV = [[UIImageView alloc]initWithFrame:CGRectMake(WIDTH/3 *2,  HEITH1/8, WIDTH/11, HEITH1/5)];
        imageV.image = [UIImage imageNamed:@"iconfont-jiaotongbuxing.png"];
        [self addSubview:imageV];
        [imageV release];
        
        
        
        self.distance = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/3 *2 +WIDTH/11, HEITH1/8, WIDTH/3, HEITH1/5)];
        self.distance.backgroundColor = [UIColor clearColor];
        self.distance.font = [UIFont systemFontOfSize:13];
        [self addSubview:self.distance];
        [self.distance release];
        
        
        self.place_name = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/5*2, HEITH1/9 * 3, WIDTH/3*2, HEITH1/5)];
        self.place_name.font = [UIFont systemFontOfSize:15];
        self.place_name.backgroundColor = [UIColor clearColor];
        [self addSubview:self.place_name];
        [self.place_name release];
        
        
      
            UIImageView *imageV1 = [[UIImageView alloc]initWithFrame:CGRectMake(WIDTH/5*2, HEITH1/10 * 6 ,  WIDTH/18,HEITH1/8)];
            imageV1.backgroundColor = [UIColor clearColor];
            [self addSubview:imageV1];
            imageV1.image = [UIImage imageNamed:@"iconfont-dianhua.png"];
            [imageV1 release];

            
        self.phone = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/6*3, HEITH1/10 * 6, WIDTH/3*2,HEITH1/8)];
        self.phone.backgroundColor = [UIColor clearColor];
        self.phone.font = [UIFont systemFontOfSize:15];
        [self addSubview:self.phone];
        [self.phone release];
        
        
        
        
        
        UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/6*3,  HEITH1/9 * 7, WIDTH/3, WIDTH/18)];
        label1.backgroundColor = [UIColor clearColor];
        [self addSubview:label1];
        [label1 release];
        
        self.imageV1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 20, 20)];
        self.imageV1.backgroundColor = [UIColor clearColor];
        [label1 addSubview:self.imageV1];
        [self.imageV1 release];
        
        
        self.imageV2 = [[UIImageView alloc]initWithFrame:CGRectMake(25, 0, 20, 20)];
        self.imageV2.backgroundColor = [UIColor clearColor];
        [label1 addSubview:self.imageV2];
        [self.imageV2 release];
        
        self.imageV3 = [[UIImageView alloc]initWithFrame:CGRectMake(50, 0, 20, 20)];
        self.imageV3.backgroundColor = [UIColor clearColor];
        [label1 addSubview:self.imageV3];
        [self.imageV3 release];
        
        self.imageV4 = [[UIImageView alloc]initWithFrame:CGRectMake(75, 0, 20, 20)];
        self.imageV4.backgroundColor = [UIColor clearColor];
        [label1 addSubview:self.imageV4];
        [self.imageV4 release];
        
        self.imageV5 = [[UIImageView alloc]initWithFrame:CGRectMake(100, 0, 20, 20)];
        self.imageV5.backgroundColor = [UIColor clearColor];
        [label1 addSubview:self.imageV5];
        [self.imageV5 release];
  
    }
    
    else{
        self.imageV = [[UIImageView alloc]initWithFrame:CGRectMake(5,self.frame.size.height /3, HEITH1 /5 *4,HEITH1 /5 *4)];
        self.imageV.backgroundColor = [UIColor whiteColor];
        self.imageV.layer.cornerRadius =(HEITH1 /5 *4)/2;
        self.imageV.layer.masksToBounds = YES;
        [self.contentView addSubview:self.imageV];
        
        self.category = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/3, HEITH1/8, WIDTH/3, HEITH1/5)];
        
        [self addSubview:self.category];
        self.category.font = [UIFont systemFontOfSize:22];
        
        
        UIImageView *imageV = [[UIImageView alloc]initWithFrame:CGRectMake(WIDTH/2,  HEITH1/8, WIDTH/11, HEITH1/5)];
        imageV.image = [UIImage imageNamed:@"iconfont-jiaotongbuxing.png"];
        [self addSubview:imageV];
        [imageV release];
        
        
        
        self.distance = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/25 *13 +WIDTH/11, HEITH1/8, WIDTH/3, HEITH1/5)];
        self.distance.backgroundColor = [UIColor clearColor];
        self.distance.font = [UIFont systemFontOfSize:20];
        [self addSubview:self.distance];
        [self.distance release];
        
        
        self.place_name = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/3, HEITH1/9 * 3, WIDTH/3*2, HEITH1/5)];
        self.place_name.font = [UIFont systemFontOfSize:19];
        self.place_name.backgroundColor = [UIColor clearColor];
        [self addSubview:self.place_name];
        [self.place_name release];
        
        
        
        UIImageView *imageV1 = [[UIImageView alloc]initWithFrame:CGRectMake(WIDTH/3, HEITH1/10 * 6, HEITH1/8, WIDTH/18)];
        imageV1.backgroundColor = [UIColor clearColor];
        [self addSubview:imageV1];
        imageV1.image = [UIImage imageNamed:@"iconfont-dianhua.png"];
        [imageV1 release];
        
        
        
        self.phone = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/5*2, HEITH1/9 * 5, WIDTH/3*2,HEITH1/5)];
        self.phone.backgroundColor = [UIColor clearColor];
        self.phone.font = [UIFont systemFontOfSize:20];
        [self addSubview:self.phone];
        [self.phone release];
        
        
        
        UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/5*2,  HEITH1/9 * 7, WIDTH/3, WIDTH/18)];
        label1.backgroundColor = [UIColor clearColor];
        [self addSubview:label1];
        [label1 release];
        
        self.imageV1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];
        self.imageV1.backgroundColor = [UIColor clearColor];
        [label1 addSubview:self.imageV1];
        [self.imageV1 release];
        
        
        self.imageV2 = [[UIImageView alloc]initWithFrame:CGRectMake(35, 0, 30, 30)];
        self.imageV2.backgroundColor = [UIColor clearColor];
        [label1 addSubview:self.imageV2];
        [self.imageV2 release];
        
        self.imageV3 = [[UIImageView alloc]initWithFrame:CGRectMake(65, 0, 30, 30)];
        self.imageV3.backgroundColor = [UIColor clearColor];
        [label1 addSubview:self.imageV3];
        [self.imageV3 release];
        
        self.imageV4 = [[UIImageView alloc]initWithFrame:CGRectMake(95, 0, 30, 30)];
        self.imageV4.backgroundColor = [UIColor clearColor];
        [label1 addSubview:self.imageV4];
        [self.imageV4 release];
        
        self.imageV5 = [[UIImageView alloc]initWithFrame:CGRectMake(125, 0, 30, 30)];
        self.imageV5.backgroundColor = [UIColor clearColor];
        [label1 addSubview:self.imageV5];
        [self.imageV5 release];

    
    }
    
   }
-(void)setFoodCM:(FoodCityModle *)foodCM{

    if (_foodCM !=nil) {
        [_foodCM release];
        _foodCM = [foodCM retain];
    }
       self.category.text = foodCM.category;
       NSInteger num = [foodCM.distance integerValue];
    if ( num> 0 && num <= 500.0) {
        
        NSString *str = [NSString stringWithFormat:@"500米内"];
        self.distance.text =str;
        
    }else if (num > 500 && num <= 1000){
    
        NSString *str = [NSString stringWithFormat:@"1公里内"];
        self.distance.text =str;
    
    
    }
    
  
    self.place_name.text = foodCM.place_name1;
    if ( foodCM.phone.length > 10) {
        NSString *string = [foodCM.phone substringToIndex:11];
        self.phone.text = string;
    }else{
    
        self.phone.text = foodCM.phone;
    }
    
    float num1 = [foodCM.star floatValue];
  
    
    if (num1 == 0.0) {
        self.imageV1.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV2.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV3.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV4.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV5.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        
    }if (num1 == 0.5) {
        
        self.imageV1.image = [UIImage imageNamed:@"iconfont-xingxingbanke.png"];
        self.imageV2.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV3.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV4.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV5.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        
    }if (num1 == 1.0) {
        self.imageV1.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV2.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV3.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV4.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV5.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
    }if (num1 == 1.5) {
        
        self.imageV1.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV2.image = [UIImage imageNamed:@"iconfont-xingxingbanke.png"];
        self.imageV3.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV4.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV5.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        
    }if (num1 == 2.0) {
        self.imageV1.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV2.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV3.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV4.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV5.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
    }if (num1 == 2.5) {
        
        self.imageV1.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV2.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV3.image = [UIImage imageNamed:@"iconfont-xingxingbanke.png"];
        self.imageV4.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV5.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        
    }if (num1 == 3.0) {
        self.imageV1.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV2.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV3.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV4.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        self.imageV5.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
        
    }if (num1 == 3.5) {
        
        self.imageV1.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV2.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV3.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV4.image = [UIImage imageNamed:@"iconfont-xingxingbanke.png"];
        self.imageV5.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
    }if (num1 == 4.0) {
        self.imageV1.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV2.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV3.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV4.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV5.image = [UIImage imageNamed:@"iconfont-shoucangxingxing.png"];
    }if (num1 == 4.5) {
        self.imageV1.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV2.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV3.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV4.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV5.image = [UIImage imageNamed:@"iconfont-xingxingbanke.png"];
    }if (num1 == 5.0) {
        self.imageV1.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV2.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV3.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV4.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
        self.imageV5.image = [UIImage imageNamed:@"iconfont-shaidanpingjia.png"];
    }
    
    
    if ([foodCM.category isEqualToString:@"烧烤"]) {
        self.imageV.image = [UIImage imageNamed:@"12504507_120011153132_2.png"];
    }
    
    else if ([foodCM.category isEqualToString:@"火锅"]) {
        self.imageV.image = [UIImage imageNamed:@"70458PICrsd.png"];
    }else if ([foodCM.category isEqualToString:@"湘菜"]){
    
        self.imageV.image = [UIImage imageNamed:@"2904530_000101706_2.png"];
    
    }else if ([foodCM.category isEqualToString:@"川菜"]){
    
        self.imageV.image = [UIImage imageNamed:@"201010281029534062.png"];
    
    }if ([foodCM.category isEqualToString:@"日韩料理"]) {
        self.imageV.image = [UIImage imageNamed:@"1005441231-0.png"];
    }if ([foodCM.category isEqualToString:@"小吃快餐"]) {
        self.imageV.image = [UIImage imageNamed:@"U6816P841DT20110928103311.png"];
    }if ([foodCM.category isEqualToString:@"面包甜点"]) {
        self.imageV.image = [UIImage imageNamed:@"10101200293_127.0.0.1_1092161441352.png"];
    }if ([foodCM.category isEqualToString:@"东北菜"]) {
        self.imageV.image = [UIImage imageNamed:@"89e623f346497635aecdadd93292f8b1_690_460.png"];
    }if ([foodCM.category isEqualToString:@"海鲜"]) {
        self.imageV.image  =[UIImage imageNamed:@"2737196_123057294000_2.png"];
    }
    
    

}
-(void)dealloc{
    [_imageV release];
    [_category release];
    [_distance release];
    [_place_name release];
    [_phone release];
    [_foodCM release];
    [_imageV1 release];
    [_imageV2 release];
    [_imageV3 release];
    [_imageV4 release];
    [_imageV5 release];
    [super dealloc];

}


@end
